<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<html>
<body>
<script type="text/javascript" src="/admin/js/ajaxfileupload.js" charset="UTF-8"></script>
<script language="javascript" type="text/javascript">
	
	function change() {
		if($("#type").val() == 2){
			$("#banTime").show();
		}else{
			$("#banTime").hide();
		}
	}
	
	function showSameIpAccount(){
		var form = $("#banForm");
		form.attr("action","listSameIp.do");
		form.submit();
	}
	
	function doQuery(){
		var form = $("#banForm");
		form.attr("action","querySelectId.do");
		form.submit();
	}
	
	function doBan(){
		var form = $("#banForm");
		var others = "";
		$("input:checked").each(function(){
			others += $(this).val() + "_";
		});
		$("#others").val(others);
		//alert(others);
		form.attr("action","banAccount.do");
		form.submit();
	}
	
	function uploadImages(type, fieldName) {
		  $.ajaxFileUpload({
			 type:"POST",
		  	//跟具updateP得到不同的上传文本的ID
	         url:'uploadImg.do?uploadId='+type,             //需要链接到服务器地址
	         secureuri:false,
	         fileElementId:type,                         //文件选择框的id属性（必须）
	         dataType: 'json',  
	         success: function (data, status){  
	        	 var filePath = data.filePath;
	        	 if(filePath.indexOf("too_large")>=0) {
	        		 alert("上传文件太大!");
	        	 } else if(filePath.indexOf("error")>=0) {
	        		 alert("上传出错!");
	        	 } else {
	        	  //debugger;
	        		$("#"+fieldName).val(filePath);
		        	$("#showPic").attr("src","http://image.upload.kugou.com/"+filePath)
	        	 }
	         },
	         error: function(data, status, e){
	        	 alert("上传失败！"+e);
	         }
		  });
	}

</script>

<ul class="breadcrumb">
  <li><a>封号 禁言 </a></li>
</ul>

<form id="banForm" class="form-horizontal" action="" method="post">
	<div class="control-group">
		<label class="control-label"for="playerId">玩家ID:</label>
		<div class="controls">
		  <input type="text" placeholder="账号ID" name="id" id="playerId" value="${id}">
		 <button type="button" class="btn" onclick="showSameIpAccount();">加载同ip账号</button>
		</div>
	</div>
	
	<c:if test="${!empty sameDetail}">
	<div class="control-group">
		<div class="controls">
			<table class="table table-bordered" style="max-width:90%;">
				  <thead>
				    <tr>
				      <th></th>
				      <th>id</th>
				      <th>昵称</th>
				      <th>等级</th>
				      <th>分贝</th>
				      <th>k币</th>
				      <th>ip</th>
				      <th>最近登陆时间</th>
				      <th>创建时间</th>
				    </tr>
				  </thead>
				  <tbody id="detail">
				  <c:forEach var="s" items="${sameDetail}">
				  <tr>
				  	  <td>
				  	  	<input type="checkbox" class="checkbox" checked="checked" value="${s.playerId}">
				  	  </td>
					  <td>
					  	${s.playerId}
					  </td>
					  <td>
					  	<tags:user id="${s.playerId}"></tags:user>
					  </td>
					  <td>
					  	lv ${s.level}
					  </td>
					  <td>
					  	${s.silver}
					  </td>
					  <td>
					  	${s.golden}
					  </td>
					  <td>
					  	<label class="area" >${s.ip}</label>
					  </td>
					  <td>
					  	${s.at_time}
					  </td>
					   <td>
					  	${s.createTime}
					  </td>
				  </tr>
				  </c:forEach>
				  </tbody>
			</table>
		</div>
		<input type="hidden" name="others" id="others" value=""/>
		</div>
	</c:if>
	
	<div class="control-group">
		<label class="control-label" for="type">类型 :</label>
		<div class="controls">
		  <select class="input-small" name="type" id="type" onChange="change()">
		  	<option value="1" id="banAccount" selected > 封号  </option>
		  	<option value="2" id="banSay"> 禁言  </option>
		  </select>
		 <span id="banTime" style="display:none;margin-left:25px;">
		 	  禁言时间： <input type="text" class="input-mini" name="time" id="time"> 分钟
		 </span>
		</div>
	</div>
	<div class="control-group">
		<label class="control-label" for="type">原因截图 :</label>
		<div class="controls">
		<input type="hidden" name="reasonImgUrl" id="reasonImgUrl" value="${reasonImgUrl}" />
		<input type="file" id="reasonImg" name="reasonImg"/>
		<input type="button" value="上传图片" class="btn control" onClick="uploadImages('reasonImg','reasonImgUrl')"/>
		</div>
	</div>
	
	<div class="control-group">
		<div class="controls">
		<img src=""  name="showPic" id="showPic" width="450px" height="450px"> 
		</div>
	</div>
	<div class="control-group">
		<label class="control-label" for="reason">原因: </label>
		<div class="controls">
		  <textarea class="input-large" row="4" name="reason" id="reason"></textarea>
		  <button type="button" class="btn control" onclick="doBan();"> 确定   </button>
		</div>
	</div>
	
	<div class="control-group">
		<label class="control-label" for="reason">被封id: </label>
		<div class="controls">
		  <input type="text" name="selectId" value=""/>
		  <button type="button" class="btn control" onclick="doQuery();"> 查询   </button>
		</div>
	</div>
</form>

<table class="table table-bordered">
  <thead>
    <tr>
      <th width="10%">时间</th>
      <th width="10%">id</th>
      <th width="10%">昵称</th>
      <th width="5%">状态</th>
      <th width="15%">原因</th>
      <th width="7%">操作记录</th>
      <th width="5%">执行人</th>
      <th width="10%">解禁时间</th>
      <th width="5%">操作</th>
    </tr>
  </thead>
  <tbody>
  <c:forEach var="player" items="${list}">
    <tr>
      <td>${player.createAt}</td>
      <td>${player.userId}</td>
      <td><tags:user id="${player.userId}"/></td>
      <c:if test="${player.status==1}">
	      <td>封号</td>
      </c:if>
      <c:if test="${player.status==2}">
	      <td>禁言</td>
      </c:if>
       <td>${player.remark}</td>
       <td><a target="_blank" href="banRecord.do?playerId=${player.userId}">查看</a></td>
       <td> ${player.operator}</td>
       <td>${player.banSpeakTime}</td>
      <td> <a href="releaseBan.do?id=${player.id}&type=${player.status}&playerId=${player.userId}"> 解封 </a>  </td>
    </tr>
  </c:forEach>
  </tbody>
</table>
<c:if test="${!empty list}">
<tags:page1 page="${page}" pageSize="${pageSize}" total="${total}" url="banAccount.do?page="/>
</c:if>
</body>
</html>